<?php
	echo form_open('bur/detail_deferred_payment_request/reroute', array('id' => 'header_form'));
	
	foreach ($semesters as $idx => $val) {
		$semesters[$idx] = $val._MED_SEP;
	}
	
	echo form_hidden('target', $controller.'/'.$this->uri->segment(3, ''));
	echo form_hidden('param', 'bulan, semester');
?>

<table class="table" style="width: auto">
<tr><td class="th">Bulan</td><td><?=form_dropdown('bulan', array('01' => 'Januari', '02' => 'Februari', '03' => 'Maret', '04' => 'April', '05' => 'Mei', '06' => 'Juni', '07' => 'Juli', '08' => 'Agustus', '09' => 'September'._MED_SEP, '10' => 'Oktober', '11' => 'November', '12' => 'Desember'), $bulan, 'style="border: 0" onchange="this.form.submit()"')?></td><td class="spacer"></td><td class="th">Semester</td><td><?=form_dropdown('semester', $semesters, $semester, 'style="border: 0" onchange="this.form.submit()"')?></td><td class="spacer"></td><td class="th">Print FPPBP</td><td><?=anchor($detail_controller.'/batch_report/pdf/1/'.$bulan.'/'.$semester, 'single PDF')?></td><td><?=anchor($detail_controller.'/batch_report/zip/1/'.$bulan.'/'.$semester, 'multiple PDFs (zip)')?></td></tr>
</table>

<?php
	echo form_close();
?>


<?php
	echo form_open('bur/detail_deferred_payment_request/bulk_action', array('id' => 'input_form'));
	echo form_hidden('bulan', $bulan);
	echo form_hidden('semester', $semester);
	
	$angkatan_filter = array();
	$angkatan_filter['function(){return true;}'] = 'Angkatan';
	foreach($peer_years as $idx => $val) {
		$angkatan_filter['function(val){return val.substr(3, 2)==\''.substr($val, -2).'\';}'] = $val;	
	}
	
	$status_filter = array();
	$status_filter['function(){return true;}'] = 'All';
	$status_filter['function(val){return !val;}'] = '(empty)';			
	foreach($statuses as $idx => $val) {		
		$status_filter['function(val){return val==\''.$val.'\';}'] = $val;	
	}
?>

<table class="table table-autosort:1 sort07 table-stripeclass:alternate" id="table-bursar" style="width:auto">
<thead>
<tr>
	<th class="filterable"><?=form_checkbox('', '', false, 'onclick="check_all(\'input_form\')"')?></th>
	<th class="table-sortable:alphanumeric filterable">NIM</th>
	<th class="table-sortable:alphanumeric filterable">Nama</th>
	<th class="table-sortable:alphanumeric filterable">Status</th>
	<th class="table-sortable:numeric_comma filterable">Total</th>
	<th>Aksi</th>
	<th>FPPBP</th></tr>
<tr>
	<th class="sth"><?php/*form_dropdown('__filter', array('function(){return true;}' => '*', 'function(val){return val;}' => 'X', 'function(val){return !val;}' => '-'), '', 'onkeyup="Table.filter(this,this)" onchange="Table.filter(this,this)"')*/?></th>
	<th class="sth"><?=form_dropdown('', $angkatan_filter, '', 'onkeyup="Table.filter(this,this)" onchange="Table.filter(this,this)"')?></th>
	<th class="sth"><?=form_input('', '', 'onkeyup="Table.filter(this,this)"')?></th>
	<th class="sth"><?=form_dropdown('', $status_filter, '', 'onkeyup="Table.filter(this,this)" onchange="Table.filter(this,this)"')?></th>
	<th class="sth"></th>
	<th class="sth"></th>
	<th class="sth"></th>
</tr>
</thead>
<tbody>
<?php

	function _format($number)
	{
		if (is_numeric($number))
			return number_format($number, 2, ',', '.');
	}

	foreach ($data as $idx => $val) {
?>
	<tr>
		<td><?=form_checkbox('students[]', $val['nim'])?></td>
		<td><?=$val['nim']?></td>
		<td><?=$val['nama']?></td>
		<td><?=$val['status']?></td>
		<td align="right"><?=_format($val['total'])?anchor($detail_controller.'/view/'.$val['nim'].'/'.$bulan.'/'.$semester, _format($val['total'])):""?></td>
		<td><?=anchor($detail_controller.'/update/'.$val['nim'].'/'.$bulan.'/'.$semester, 'update')?><?=_MED_SEP?><?=anchor($detail_controller.'/approve_request/'.$val['nim'].'/'.$bulan.'/'.$semester, 'approve')?><?=_MED_SEP?><?=anchor($detail_controller.'/unapprove_request/'.$val['nim'].'/'.$bulan.'/'.$semester, 'unapprove')?></td>
		<td><?=anchor_popup($detail_controller.'/report/html/1/'.$val['nim'].'/'.$bulan.'/'.$semester, '<img src="'.base_url().'images/icons/fileicons/html.png" title="Download Lember Kontrol (HTML)" alt="HTML" class="noborder" />')?><?=_MED_SEP?><?=anchor($detail_controller.'/report/pdf/1/'.$val['nim'].'/'.$bulan.'/'.$semester, '<img src="'.base_url().'/images/icons/fileicons/pdf.png" title="Download Lembar Kontrol (PDF)" alt="PDF" class="noborder" />')?></td>
	</tr>
<?php
	}
?>
</tbody>
<tfoot>
	<tr><td colspan="2" align="right">with selected</td><td colspan="7"><?=form_submit('__submit', 'Download Kuitansi (PDF)')?> <?=form_submit('__submit', 'Download Kuitansi (ZIP)')?> <?=form_submit('__submit', 'Setujui Permohonan')?> <?=form_submit('__submit', 'Tolak Permohonan')?></td></tr>
</tfoot>
</table>

<?php
	echo form_close();
?>

<script type="text/javascript">
checked = false;
function check_all(form) {
	var _form = document.getElementById(form);
	checked = !checked;
	for (var i =0; i < _form.elements.length; i++) 
	{
	 _form.elements[i].checked = checked;
	}
      }
</script>
